﻿window.fbAsyncInit = function () {
    FB.init({
        appId: APP_ID,
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true
    });
    FB.Event.subscribe('auth.statusChange', function(response) {
        if (response.authResponse) {
            var accessToken = response.authResponse.accessToken;
            $("#authToken").val(accessToken);
            $("#authForm").submit();
        }
    });
};

(function (d) {
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
} (document));